|
|
|
| ", " & mstrFirstName & vbCrLf
MsgBox strMsg
End Sub |  | Although this method doesnt perform anything very useful, it does get across the point that a method is simply Visual Basic code that operates on data within the class and returns that data in some other format. From the command button on the form, you can invoke this method with the following code: | | Private Sub cmdDisplay_Click()
Dim oEmp As Employee
Set oEmp = New Employee
oEmp.FirstName = "Bill"
oEmp.LastName = "Gates"
Call oEmp.EmployeeName End Sub | | As you can see, this simplifies the code quite a bit from the previous version, where you had to put the formatting within the command button. Now you can just call a method and it will perform the formatting for you. |
|
|
|
|
|
|
Forms are classes! What this means is that you can have properties and methods attached to a form. Actually, forms have always been classes, but prior to Visual Basic 4, it was impossible to get at the underlying architecture to change anything. Now you can treat forms just like any other user-defined class you create. |
|
|
|
|
|
|
|
|
To create a property on a form, you simply create a Private variable in the General Declarations section and then create Property Get and Property Let procedures, just like you did in the CLS files. Of course, the big question is why would you want to do this? The main reason is to get rid of global variables. |
|
|
|
|
|